<?php
//https://author.baidu.com/home/1605662285475872

if($_GET['gather_type']==6&&$_REQUEST['gongzhonghao']!=""&&preg_match("/author\.qq\.com/Uisx",$this->url,$nn)){
    $gzh = $_REQUEST['gongzhonghao'];
    $url = "https://weixin.sogou.com/weixin?type=2&s_from=input&query={$gzh}&ie=utf8&_sug_=n&_sug_type_=&zq=1";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36");
    curl_setopt($ch, CURLOPT_REFERER, "https://weixin.sogou.com/weixin?type=2&query={$gzh}&ie=utf8&s_from=input&_sug_=n&_sug_type_=");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language:  zh-CN,zh;q=0.9"));
    if($this->cookie!=""){
        curl_setopt($ch, CURLOPT_COOKIE, $this->cookie);
    }
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, "false");
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, "2");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host:  weixin.sogou.com", "Connection:  keep-alive", "Accept:  text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,* / *;q=0.8,application/signed-exchange;v=b3", "Accept-Language:  zh-CN,zh;q=0.9"));
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    $result = curl_exec($ch);
    $this->clcookie($result);
    curl_close($ch);
    $arr = array();

    preg_match_all("/<h1>302\sFound<\/h1>/Uisx", $result, $nnn);
    if(count($nnn[0])>0){
        $result=$this->zqtitle();
        return $result;
    }

    preg_match_all("/请输入验证码/Uisx", $result, $nnn);
    if(count($nnn[0])>0){
        if(preg_match_all("/(<form[^<>]+seccodeForm[^<>]+>.*<\/form>)/Uisx",$result,$nn)){
            $nn[0][0]=preg_replace_callback("/src=\"([^<>]*)\"/Uisx",function($em){
                $em[1]="/admin/news/gzhnews/createyzm?url=".urlencode("https://weixin.sogou.com/antispider/".$em[1]);
                return "src=\"{$em[1]}\"";
            },$nn[0][0]);
            $nn[0][0]=str_replace("padding-left:50px;","padding-left:-5px;",$nn[0][0]);
            $nn[0][0]=str_replace("action=\"/\"","action=\"https://weixin.sogou.com/\"",$nn[0][0]);
            echo json_encode(array("retCode" => 9, "retMsg"=>"请输入验证码","template"=>$nn[0][0]));
            exit(0);
        }
    }


    preg_match_all("/<\!\-\-\s*a\s*\-\->(.*)<\!\-\-\s*z\s*\-\->/Uisx", $result, $nnn);
    if(count($nnn[1])<1){
        echo json_encode(array("retCode" => 0, "retMsg"=>"该微信号暂时没有信息！"));
        exit(0);
    }
    $result=array();
    $result['counts']=0;
    for ($i = 0; $i < count($nnn[1]); $i++) {
        $atitlenr = $nnn[1][$i];
        $data = array();
        $result['counts'] = $result['counts'] + 1;
        //计算链接
        preg_match("/<h3>\s+<a\s+target=\"_blank\"\s+href=\"([^<>]*)\"/Uisx", $atitlenr, $nn);
        $nn[1] = "https://weixin.sogou.com" . $nn[1] . "&query={$gzh}&k=24&h=X";
        $data['sourceurl'] = $nn[1];

        //计算来源
        preg_match("/\(来源\:(.*)\)/Uisx", $atitlenr, $nn);
        if (!empty($nn)) {
            $nn[1] = strip_tags($nn[1]);
            $data['source'] = $nn[1];
        }


        //计算标题
        preg_match("/<h3>\s+<a[^<>]*>(.*)<\/a>\s+<\/h3>/Uisx", $atitlenr, $nn);
        if (!empty($nn)) {
            $nn[1] = strip_tags($nn[1]);
            $data['title'] = $nn[1];
        }

        //计算简介
        preg_match("/<p\s+class=\"txt\-info\"[^<>]*>(.*)<\/p>/Uisx", $atitlenr, $nn);
        if (!empty($nn)) {
            $nn[1] = strip_tags($nn[1]);
            $data['info'] = $nn[1];
        }

        //计算时间
        preg_match("/document\.write\(timeConvert\('(.*)'\)\)/Uisx", $atitlenr, $nn);
        $data['dateline'] = $nn[1];

        //公众号
        $data['gzh'] = $gzh;
        $data['content'] = $this->zqGzNr($data['sourceurl'], $data['dateline']);

    }

}

if($_GET['gather_type']==6&&preg_match("/\/omn\/author\/([0-9]+)/isx",$this->url,$nn)){
//    $url="https://pacaio.match.qq.com/om/mediaArticles?mid=".$nn[1]."&num=15&page=0&expIds=&callback=__jp0";
//    $zqindex=$this->redo($url);
//    if(!empty($zqindex->result)){
//        $zqindex->toendjson();
//    }
}



if($_GET['gather_type']==6&&preg_match("/mediaArticles/Uisx",$this->url,$nn)){
    $c=$GLOBALS['mycurl'];
    $c->result("",$this->url);
    $url=$this->url;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language:  en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ja;q=0.6,bg;q=0.5"));
    curl_setopt($ch, CURLOPT_COOKIE,$c->cookie);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, "false");
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, "2");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,0);
    curl_setopt($ch, CURLOPT_VERBOSE,1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host:  pacaio.match.qq.com","Connection:  keep-alive","Accept:  text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","Accept-Language:  en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ja;q=0.6,bg;q=0.5"));
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    $result=curl_exec($ch);
    curl_close($ch);
    $c->result($result,$url);
    $pagehtml=$c->body;
    $c->setListResult($c->jsdata['data'],"title","url","timestamp");
}